<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>编辑图片</h2>
    </div>
    <form action="{:U()}" method="post" class="form-horizontal" enctype="multipart/form-data">
        <div class="form-item">
            <label class="item-label">商品名称:{$res['title']}</label>
            <div class="controls">
                <select name="gid">
                        <option value="">请选择</option>
                    <foreach name="res" item="v">
                        <option value="{$v['id']}">{$v.title}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">上传图片</label>
            <div style="height:100px;">
                <img src="" id="pic1" style="width:100px;height:100px;">
                <img src="" id="pic2" style="width:100px;height:100px;margin-left:100px;">
                <img src="" id="pic3" style="width:100px;height:100px;margin-left:100px;">
                <img src="" id="pic4" style="width:100px;height:100px;margin-left:100px;">
                <img src="" id="pic5" style="width:100px;height:100px;margin-left:100px;">
                <img src="" id="pic6" style="width:100px;height:100px;margin-left:100px;">
            </div>
            <hr>
            <div id="upload-img">
                <input type="file" name="pic[]" id="img1" style="width:200px;">
                <input type="file" name="pic[]" id="img2" style="width:200px;">
                <input type="file" name="pic[]" id="img3" style="width:200px;">
                <input type="file" name="pic[]" id="img4" style="width:200px;">
                <input type="file" name="pic[]" id="img5" style="width:200px;">
                <input type="file" name="pic[]" id="img6" style="width:200px;">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">状态</label>
            <div class="controls">
                <label class="radio">
                    <input type="radio" name="status" value="1">显示
                    <input type="radio" name="status" value="0">不显示
                </label>
            </div>
        </div>
        <br>
        <div class="form-item">
            <button class="btn submit-btn" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Property/index')}');

        $(function(){
            $("#img1").on("change",function(){
                var sel = $(this);
                var input = "";
                var objUrl = getObjectURL(this.files[0]) ; //获取图片的路径，该路径不是图片在本地的路径
                if (objUrl) {
                $("#pic1").attr("src", objUrl) ; //将图片路径存入src中，显示出图片
                }
                });
            $("#img2").on("change",function(){
                var sel = $(this);
                var input = "";
                var objUrl = getObjectURL(this.files[0]) ; //获取图片的路径，该路径不是图片在本地的路径
                if (objUrl) {
                $("#pic2").attr("src", objUrl) ; //将图片路径存入src中，显示出图片
                }
                });
            $("#img3").on("change",function(){
                var sel = $(this);
                var input = "";
                var objUrl = getObjectURL(this.files[0]) ; //获取图片的路径，该路径不是图片在本地的路径
                if (objUrl) {
                $("#pic3").attr("src", objUrl) ; //将图片路径存入src中，显示出图片
                }
                });
            $("#img4").on("change",function(){
                var sel = $(this);
                var input = "";
                var objUrl = getObjectURL(this.files[0]) ; //获取图片的路径，该路径不是图片在本地的路径
                if (objUrl) {
                $("#pic4").attr("src", objUrl) ; //将图片路径存入src中，显示出图片
                }
                });
            $("#img5").on("change",function(){
                var sel = $(this);
                var input = "";
                var objUrl = getObjectURL(this.files[0]) ; //获取图片的路径，该路径不是图片在本地的路径
                if (objUrl) {
                $("#pic5").attr("src", objUrl) ; //将图片路径存入src中，显示出图片
                }
                });
            $("#img6").on("change",function(){
                var sel = $(this);
                var input = "";
                var objUrl = getObjectURL(this.files[0]) ; //获取图片的路径，该路径不是图片在本地的路径
                if (objUrl) {
                $("#pic6").attr("src", objUrl) ; //将图片路径存入src中，显示出图片
                }
                });

            function getObjectURL(file) {
                var url = null ;
                if (window.createObjectURL!=undefined) { // basic
                url = window.createObjectURL(file) ;
                } else if (window.URL!=undefined) { // mozilla(firefox)
                url = window.URL.createObjectURL(file) ;
                } else if (window.webkitURL!=undefined) { // webkit or chrome
                url = window.webkitURL.createObjectURL(file) ;
                }
                return url ;
            }
        });
    </script>
</block>
